package com.example.myapplication;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class Basic extends AppCompatActivity {
    private TextView tv_name;
    private TextView tv_phoneNumber;
    private TextView tv_password;
    private Button btn_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("MainActivityLife", "调用onCreate()");
        Button button_1 = (Button) findViewById(R.id.button);
        button_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                intent.setData(Uri.parse("http://www.baidu.com"));
                startActivity(intent);
            }
        });

        Button button_2 = (Button) findViewById(R.id.button2);
        button_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = getPackageManager().getLaunchIntentForPackage("tv.danmaku.bili");   //打开bilibili
                startActivity(intent);
            }
        });

        Button button_3 = (Button) findViewById(R.id.button3);
        button_3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = getPackageManager().getLaunchIntentForPackage("com.tencent.mm");   //打开微信
                startActivity(intent);
            }
        });

        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        String phoneNumber = intent.getStringExtra("phoneNumber");
        String password = intent.getStringExtra("password");
        tv_name = (TextView) findViewById(R.id.tv_name);
        tv_phoneNumber = (TextView) findViewById(R.id.tv_phone);
        tv_password = (TextView) findViewById(R.id.tv_psw);
        tv_name.setText("手机号：" + name);
        tv_phoneNumber.setText("验证码：" + phoneNumber);
        tv_password.setText("密码：" + password);
        btn_back = (Button) findViewById(R.id.btn_back);
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                backDate();
            }
        });
    }

    public void backDate() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivityForResult(intent, 1);
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.i("MainActivityLife", "调用onStart()");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.i("MainActivityLife", "调用onResume()");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.i("MainActivityLife", "调用onPause()");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i("MainActivityLife", "调用onStop()");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i("MainActivityLife", "调用onDestroy()");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i("MainActivityLife", "调用onRestart()");
    }
}